package com.zxs.product.controller;

import com.zxs.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import parm.ProductIdsParam;
import utils.R;

/**
 * @author zxs
 * *8 16:53
 */

@RestController
@RequestMapping("product")
public class ProductCollectController {

    @Autowired
    private ProductService productService;

    /***
     * 查看收藏的列表商品id集合
     * @param productIdsParam
     * @param result
     * @return
     */
    @PostMapping("collect/list")
    public R collectList(@RequestBody @Validated ProductIdsParam productIdsParam, BindingResult result){
        if (result.hasErrors()){
            return  R.fail("收藏列表为空，赶紧收藏你喜欢的物品吧！！！");
        }
        return  productService.collectList(productIdsParam.getProductIds());
    }
}
